home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / misc / libframe.lha / LibFrame.asm next >
Assembly Source File  |  1995-09-30  |  5KB  |  173 lines

  1. ;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2. ;»»»»»
  3. ;»»»»»  $VER: xyz.library 1.0 (22.4.95)
  4. ;»»»»»
  5. ;»»»»»  Framework by Dennis Jacobfeuerborn.
  6. ;»»»»»
  7. ;»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  8.  
  9.         OPT     O+
  10.         SECTION xyz,CODE
  11.  
  12. LIBNAME         MACRO
  13.         Dc.b    "xyz.library",0
  14.         ENDM
  15. LIBVERSION      MACRO
  16.         Dc.b    "$VER: xyz.library 1.0 (day.month.year)",0
  17.         ENDM
  18.  
  19. VERSION         =       1
  20. REVISION        =       0
  21.  
  22. ;Begin »»»»» INCLUDES ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  23.         IncDir  ASMInclude:
  24.         Include My/Macros.I
  25.  
  26.         Include Exec/Execbase.i
  27.         Include Exec/Exec.i
  28.         Include Exec/Types.i
  29.         Include Exec/Initializers.i
  30.         Include Exec/Libraries.i
  31.         Include Exec/Lists.i
  32. ;End
  33. ;Begin »»»»» STRUCTURES ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  34.         INITVARS        OOPSBase,LIB_SIZE
  35.             BVAR    Flags
  36.             BVAR    Pad0
  37.             LVAR    SysBase
  38.             LVAR    SegList
  39.         ENDVARS         OOPSBase
  40.  
  41.         INITVARS        GlobalVars,0
  42.             LVAR    ReturnCode
  43.         ENDVARS         GlobalVars
  44. ;End
  45.  
  46. ;Begin »»»»» Dummy Startup-code ««««««««««««««««««««««««««««««««««««««««««««««««««««
  47.         Moveq   #-1,d0                  ; Don't even try to run me !!!
  48.         Rts
  49. ;End
  50. ;Begin »»»»» ROMTag Structure ««««««««««««««««««««««««««««««««««««««««««««««««««««««
  51. ROMTag          Dc.w    RTC_MATCHWORD   ;uword  rt_matchword
  52.         Dc.l    ROMTag          ;aptr   rt_matchtag
  53.         Dc.l    EndOfLib        ;aptr   rt_endskip
  54.         Dc.b    RTF_AUTOINIT    ;ubyte  rt_flags
  55.         Dc.b    VERSION         ;ubyte  rt_version
  56.         Dc.b    NT_LIBRARY      ;ubyte  rt_type
  57.         Dc.b    0               ;ubyte  rt_pri
  58.         Dc.l    LibraryName     ;aptr   rt_name
  59.         Dc.l    LibraryID       ;aptr   rt_idstring
  60.         Dc.l    InitTable       ;aptr   rt_init
  61. ;End
  62. ;Begin »»»»» Library Names & ID ««««««««««««««««««««««««««««««««««««««««««««««««««««
  63. LibraryName     LIBNAME
  64. LibraryID       LIBVERSION
  65.         Even
  66. ;End
  67. ;Begin »»»»» Library Initialisation Table ««««««««««««««««««««««««««««««««««««««««««
  68. InitTable       Dc.l    OOPSBase_SIZE           ;structure size (library base)
  69.         Dc.l    FunctionTable           ;function list
  70.         Dc.l    LibBaseData             ;information for initializing
  71.         Dc.l    InitRoutine             ;own routine for initialization
  72. ;End
  73. ;Begin »»»»» Library Function Table ««««««««««««««««««««««««««««««««««««««««««««««««
  74. FunctionTable   Dc.l    Open                    ; The basic lib functions
  75.         Dc.l    Close
  76.         Dc.l    Expunge
  77.         Dc.l    Null
  78.  
  79.         Dc.l    Place your functions here !
  80.         Dc.l    -1
  81. ;End
  82. ;Begin »»»»» LibBaseData «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  83. LibBaseData     INITBYTE        LN_TYPE,NT_LIBRARY
  84.         INITLONG        LN_NAME,LibraryName
  85.         INITBYTE        LIB_FLAGS,LIBF_SUMUSED!LIBF_CHANGED
  86.         INITWORD        LIB_VERSION,VERSION
  87.         INITWORD        LIB_REVISION,REVISION
  88.         INITLONG        LIB_IDSTRING,LibraryID
  89.         Dc.l            0       ;end!
  90. ;End
  91.  
  92. ;Begin »»»»» InitRoutine «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  93. InitRoutine     Movem.l d2-d7/a2-a6,-(sp)
  94.         Move.l  d0,a5
  95.  
  96.         VPUT.l  a6,SysBase
  97.         VPUT.l  a0,SegList
  98.  
  99.         Move.l  a5,d0
  100.         Movem.l (sp)+,d2-d7/a2-a6
  101.         Rts
  102.  
  103. .Free           Moveq   #0,d0
  104.         Move.l  a5,a1
  105.         Move.w  LIB_NEGSIZE(a5),d0
  106.         Sub.l   d0,a1
  107.         Add.w   LIB_POSSIZE(a5),d0
  108.         CALL    FreeMem
  109.         Movem.l (sp)+,d2-d7/a2-a6
  110.         Moveq   #0,d0
  111.         Rts
  112. ;End
  113. ;Begin »»»»» Open ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  114. Open            Addq.w  #1,LIB_OPENCNT(a6)
  115.         BClr    #LIBB_DELEXP,var_Flags(a6)
  116.         Move.l  a6,d0
  117.         Rts
  118. ;End
  119. ;Begin »»»»» Close «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  120. Close           Subq.w  #1,LIB_OPENCNT(a6)
  121.         Bne.s   Close_NotLast
  122.  
  123.         BTst    #LIBB_DELEXP,var_Flags(a6)
  124.         Beq.s   Close_NoDelayedExpunge
  125.  
  126.         Bsr.s   Expunge
  127. Close_NoDelayedExpunge
  128. Close_NotLast   Moveq   #0,d0
  129.         Rts
  130. ;End
  131. ;Begin »»»»» Expunge «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  132. Expunge         Move.l  a5,-(sp)
  133.         Move.l  a6,a5
  134.         VGET.l  SysBase,a6
  135.  
  136.         Tst.w   LIB_OPENCNT(a5)
  137.         Beq.s   Expunge_Ok
  138.  
  139.         BSet    #LIBB_DELEXP,var_Flags(a5)
  140.         Move.l  a5,a6
  141.         Move.l  (sp)+,a5
  142.         Moveq   #0,d0
  143.         Rts
  144.  
  145. Expunge_Ok      Move.l  d2,-(sp)
  146.  
  147.         VGET.l  SegList,d2
  148.  
  149.         Move.l  a5,a1
  150.         CALL    Remove
  151.  
  152.         Moveq   #0,d0
  153.         Move.l  a5,a1
  154.         Move.w  LIB_NEGSIZE(a5),d0
  155.         Sub.l   d0,a1
  156.         Add.w   LIB_POSSIZE(a5),d0
  157.         CALL    FreeMem
  158.         Move.l  d2,d0
  159.  
  160.         Move.l  (sp)+,d2
  161.         Move.l  a5,a6
  162.         Move.l  (sp)+,a5
  163.         Rts
  164. ;End
  165. ;Begin »»»»» Null ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
  166. Null            Moveq   #0,d0
  167.         Rts
  168. ;End
  169.     ;*** your routines starting from -30 ...
  170.  
  171. EndOfLib
  172.     END
  173.